<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<title>添加主题--管理后台</title>
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript"src="/js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
        $(function () {
            initNewsList();
        })
        function initNewsList(ntid) {
            if (ntid == undefined||ntid == null)ntid = 0;
            $.getJSON("/news.do",{"opr":"getNewsByPage","ntid":ntid,"currPageNo":1,"pageSize":15},function (result) {
                $(".classList").empty();
                if(result == null){
                    $(".classlist").html("请求失败！");
                }else if(result.toleCount == 0){
                    $(".classlist").html("抱歉没有找到相关的新闻！");
                }else {
                    $(result.data).each(function (i, news) {
                        $(".classlist").append(
                            "<li>" +
                            news.ntitle + "<span> 作者：" + news.nauthor + "&#160;&#160;&#160;&#160;\n" +
                            "<a href='/news.do?opr=update&nid=news.nid'>修改</a> &#160;&#160;&#160;&#160;\n" +
                            "<a href='/news.do?opr=del' onclick='return clickdelnews.nid'>删除</a></span> " +
                            "</li>"
                        );
                        if ((i + 1) % 5 == 0) {
                            $(".classlist").append("<li class='space'><li>");
                        }
                        $("#currPageNo").html(result.currPageNo);
                        $("#totalPageCount").html(result.totalPageCount);
                        $("#totalCount").html(result.totaCount);
                    })
                }
            })
        }
    </script>

</head>
<body>
<div id="header">
  <div id="welcome">欢迎使用新闻管理系统！</div>
  <div id="nav">
    <div id="logo"><img src="../images/logo.jpg" alt="新闻中国" /></div>
    <div id="a_b01"><img src="../images/a_b01.gif" alt="" /></div>
  </div>
</div>
<div id="admin_bar">
  <div id="status">管理员： 登录  &#160;&#160;&#160;&#160; <a href="#">login out</a></div>
  <div id="channel"> </div>
</div>
<div id="main">
  <%@ include file="console_element/left.html" %>
  <div id="opt_area">    
    <script type="text/javascript" >
    function clickdel(nid){
        if (confirm("此新闻的相关评论也将删除，确定删除吗？"))
            window.location="../util/news?opr=delete&nid="+nid;
    }
	
</script>
    <ul class="classlist">
      <c:forEach items="${sessionScope.list}" var="news" varStatus="i">

	    <c:if test="${i.count % 5 == 0}">
          <li class='space'></li>
        </c:if>
	  </c:forEach>
	  <c:remove var="list" scope="session"/>
    </ul>
      <p align="center">
          当前页数:[<span id="currPageNo"></span>/<span id="totalPageCount"></span>]&nbsp;
          总页数：<span id="totalCount"></span>
      </p>
  </div>
</div>
<div id="footer">
  <%@ include file="console_element/bottom.html" %>
</div>
</body>
</html>